package functions;

import java.util.Map;
import org.json.JSONObject;
import coms.Constants;
import frame.HttpHelper;
import frame.InterTest;

/**
 * 
 * @author zhuyi
 * 
 */
public class QueryPayPlan implements InterTest{

	
	private String guishuCompany;
	private String datestart;
	private String dateend;
	private String invoiceNo;
	private String result;
	
	
	public QueryPayPlan(String guishuCompany, String datestart,String dateend,String invoiceNo) {
		
		this.invoiceNo= invoiceNo;
		this.guishuCompany = guishuCompany;
		this.datestart = datestart;
		this.dateend = dateend;
	
	}
	
	public void query() {
		String url = Constants.QUERY_PAY_PLAN_URL;
		//String params="{\"page\":{\"currentPage\":1,\"pageSize\":10,\"recordCount\":0},\"params\":{\"ouCode\":\"CQYY0\",\"payType\":\"\",\"payPlandueDate\":[\"2018-05-31T16:00:00.000Z\",\"2018-06-29T16:00:00.000Z\"],\"payPlandueDateFrom\":\"2018-06-01\",\"payPlandueDateTo\":\"2018-06-30\",\"vendorName\":\"\",\"queryType\":\"\",\"glDateFrom\":\"\",\"glDateTo\":\"\",\"invoiceNo\":\"\",\"vendorCode\":\"\",\"invoiceDateFrom\":\"\",\"invoiceDateTo\":\"\",\"projectCode\":\"\",\"projectName\":\"\",\"currency\":\"\",\"createdPayRequest\":\"\",\"requestPaymentTypeName\":\"\",\"categoryCode\":\"\",\"glDate\":[\"\",\"\"],\"invoiceDate\":[\"\",\"\"]},\"sortDTO\":{\"fieldName\":\"\",\"orderBy\":\"\"}}";
		String params = "{\"page\":{\"currentPage\":1,\"pageSize\":10,\"recordCount\":0},\"params\":{\"ouCode\":\""+guishuCompany+"\",\"payType\":\"\",\"payPlandueDate\":[\"2018-05-31T16:00:00.000Z\",\"2018-06-29T16:00:00.000Z\"],\"payPlandueDateFrom\":\""+datestart+"\",\"payPlandueDateTo\":\""+dateend+"\",\"vendorName\":\"\",\"queryType\":\"\",\"glDateFrom\":\"\",\"glDateTo\":\"\",\"invoiceNo\":\""+invoiceNo+"\",\"vendorCode\":\"\",\"invoiceDateFrom\":\"\",\"invoiceDateTo\":\"\",\"projectCode\":\"\",\"projectName\":\"\",\"currency\":\"\",\"createdPayRequest\":\"\",\"requestPaymentTypeName\":\"\",\"categoryCode\":\"\",\"glDate\":[\"\",\"\"],\"invoiceDate\":[\"\",\"\"]},\"sortDTO\":{\"fieldName\":\"\",\"orderBy\":\"\"}}";
		
		try {
			result = HttpHelper.post(params, url);
			try {
				JSONObject jsonObject = new JSONObject(result);
				System.out.println(jsonObject.toString());
				int tol = jsonObject.getInt("total");
				System.out.println("取到了"+tol+"条数据");
//				if(tol==3) {
//					
//					System.out.println("取到了"+tol+"条数据");
//				}
			} catch (Exception e) {
				e.printStackTrace();
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}



	@Override
	public void run(Map<Object, Object> paramMap) {
		// TODO Auto-generated method stub
	  query();
	}

  @Override
  public boolean getStatus() {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public String getRemark() {
    // TODO Auto-generated method stub
    return null;
  }
	
}
